/*
	TokenFactory.h
	Define CTokenFactory
	
	@author Wolfhead
*/

#pragma once

#ifndef _TOKEN_FACTORY_H_
#define _TOKEN_FACTORY_H_

#include "wfx.h"
#include "TokenBasic.h"

MAKE_PTR(CTokenFactory);

class CTokenFactory
{
public:

    static CTokenFactoryPtr Instance()
    {
        static CTokenFactoryPtr pInstance(new CTokenFactory());
        return pInstance;
    }

    ~CTokenFactory();

    template<class T> 
    static boost::shared_ptr<T> createToken(Token_Type type);

    template<class T>
    static boost::shared_ptr<T> CastToken(CTokenPtr pToken);

private:
    CTokenFactory();
};




template<class T> 
boost::shared_ptr<T>
CTokenFactory::createToken(Token_Type type = TOKEN_ERROR)
{
    boost::shared_ptr<T> p = boost::shared_ptr<T>(new T());
    p->SetType(type);
    return p;
}

template<class T>
boost::shared_ptr<T>
CTokenFactory::CastToken( CTokenPtr pToken )
{
    return boost::shared_ptr<T>(pToken);
}


#endif // #ifndef _TOKEN_FACTORY_H_